package com.smt.ejb3.tutoria.entitybean.one2one.fk;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;

@Entity
public class Customer1 implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private int id;
	private String name;
	private CustomerNo1 custNo;
	
	@Id
	@Column(name="CUST_ID")
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	@Column(name="name")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@OneToOne(cascade=CascadeType.PERSIST)
	@JoinColumn(name="CUST_ID_FK", referencedColumnName="CUSTNO_ID")
	public CustomerNo1 getCustNo() {
		return custNo;
	}
	public void setCustNo(CustomerNo1 custNo) {
		this.custNo = custNo;
	}
	
	public String toString(){
		return getName() + " " + getCustNo().getSn();
	}
}
